import { Injectable } from '@angular/core';
import {Observable, Subject} from 'rxjs';

@Injectable({
    providedIn: 'root',
})
export class MessageService {
    private subject = new Subject<any>();

    sendMessage(message: any, id: string) {
        this.subject.next({ data: message, id: id });
    }

    clearMessage() {
        this.subject.next();
    }

    getMessage(): Observable<any> {
        return this.subject.asObservable();
    }
}
